import Vue from 'vue'
import Router from 'vue-router'
// import './plugins/element.js'
import Login from './components/Login.vue'
import Home from './components/Home.vue'
import Clues from './components/Clues/Clues.vue'
import Casefile from './components/Casefile/Casefile.vue'
import CasefileDetail from './components/Casefile/CasefileDetail.vue'
import Stringcase from './components/Stringcase/Stringcase.vue'
import StringcaseDetail from './components/Stringcase/StringcaseDetail.vue'

Vue.use(Router)

const router = new Router({
    routes: [{
            path: '/',
            redirect: '/login'
        },
        {
            path: '/login',
            component: Login
        },
        {
            path: '/home',
            component: Home,
            redirect: '/clues',
            children: [
                { path: '/clues', component: Clues, meta: { activeMenu: '/clues' } },
                { path: '/casefile', component: Casefile, meta: { activeMenu: '/casefile' } },
                { path: '/casefiledetail', component: CasefileDetail, meta: { activeMenu: '/casefile' } },
                { path: '/stringcase', component: Stringcase, meta: { activeMenu: '/stringcase' } },
                { path: '/stringcasedetail', component: StringcaseDetail, meta: { activeMenu: '/stringcase' } },
            ]
        },
    ]
})

// 导航守卫
// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') return next();
//   const tokenStr = window.sessionStorage.getItem('token');

//   if (!tokenStr) return next('./login');
//   next();
// })

//路由守卫拦截
router.beforeEach((to, from, next) => {
    // if(to.path=='/login'){
    next();
    //   }else{
    //     if(sessionStorage.getItem('token')){
    //       next();
    //     }else{
    //       next('/login')
    //     }
    //   }
})

export default router